package 剑指offer;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhangjunfei
 * @date 2023/8/24 16:26
 */
public class O_50 {
    public char firstUniqChar(String s) {
        Map<Character, Boolean> dict = new HashMap<>();
        char[] chars = s.toCharArray();
        for (char aChar : chars) {
            dict.put(aChar, !dict.containsKey(aChar));
        }
        for (char aChar : chars) {
            if (dict.get(aChar)) {
                return aChar;
            }
        }
        return ' ';
    }
}
